package iotest;

import java.io.*;
import java.nio.charset.StandardCharsets;

public class BrDemo {
    public static void main(String[] args) {
        //
  /*      FileInputStream fis;
        try {
            fis=new FileInputStream("./src/iotest/BrDemo.java");
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        }
        InputStreamReader isr=new InputStreamReader(fis, StandardCharsets.UTF_8);
        BufferedReader br=new BufferedReader(isr);

        String line;
        try {
            while ((line=br.readLine())!=null){
                System.out.println(line);
            }

        } catch (IOException e) {
            throw new RuntimeException(e);
        } finally {
            try {
                if (fis!=null){
                    br.close();
                }
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }*/
        //
        try (FileInputStream fis2=new FileInputStream("./src/iotest/BrDemo.java")){
            InputStreamReader isr2=new InputStreamReader(fis2);
            BufferedReader br2=new BufferedReader(isr2);
            String len2;
            while ((len2=br2.readLine())!=null){
                System.out.println(len2);
            }
            //br2.close();
            //自动关闭流

        }catch (IOException e){
            e.printStackTrace();//打印异常信息
            System.out.println(e.getMessage());//打印异常信息
        }




    }
}
